package com.zbkj.front.controller.v2.order;

import com.zbkj.dal.base.result.CommonResult;
import com.zbkj.dal.pojo.vo.LogisticsResultVo;
import com.zbkj.dal.pojo.vo.WxPayJsResultVo;
import com.zbkj.front.model.req.OrderAddressModifyReq;
import com.zbkj.front.service.FrontOrderService;
import com.zbkj.service.model.dto.OrderPreCheckDTO;
import com.zbkj.service.model.front.req.order.OrderPreCheckReq;
import com.zbkj.service.model.front.req.order.ReserveRentReturnPickUpReq;
import com.zbkj.service.model.front.req.order.UpdateDeliveryTypeReq;
import com.zbkj.service.model.front.vo.order.AppointmentShopVo;
import com.zbkj.service.model.front.vo.order.D2dPickUpVO;
import com.zbkj.service.service.order.OrderV2Service;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.time.LocalTime;

@Deprecated
@Api(value = "订单V2")
@RestController
@RequestMapping("/api/front/v2/order")
public class OrderV2Controller {

    @Resource
    private OrderV2Service orderV2Service;
    @Autowired
    private FrontOrderService orderService;

    @GetMapping("/pre-check")
    public CommonResult<OrderPreCheckDTO> orderPreCheck(OrderPreCheckReq req) {
        return CommonResult.success(orderV2Service.orderPreCheck(req));
    }

    @ApiOperation(value = "修改配送方式", tags = "承享/买入订单")
    @PostMapping("/update/delivery-type")
    public CommonResult<Void> updateDeliveryType(@RequestBody UpdateDeliveryTypeReq req) {
        return CommonResult.success();
    }

    @ApiOperation(value = "修改配送地址", tags = "承享/买入订单")
    @PostMapping("/update/address")
    public CommonResult<?> updateAddress(@RequestBody OrderAddressModifyReq req) {
        orderService.orderAddressModify(req);
        return CommonResult.success();
    }

    @ApiOperation(value = "获取微信支付参数", tags = "承享/买入订单")
    @GetMapping("/pay/param")
    public CommonResult<WxPayJsResultVo> payParam(@RequestParam("orderNo") String orderNo) {
        WxPayJsResultVo wxPayJsResultVo = new WxPayJsResultVo();
        return CommonResult.success(wxPayJsResultVo);
    }

    @ApiOperation(value = "订单物流信息", tags = "承享/买入订单")
    @GetMapping("/delivery/info")
    public CommonResult<LogisticsResultVo> orderDeliveryInfo(@RequestParam("invoiceId") Integer invoiceId) {
        return CommonResult.success(orderService.getOrderDeliveryInfo(invoiceId));
    }

    @ApiOperation(value = "上门取件", tags = "承享/买入订单")
    @PostMapping("/return/door-to-door/pick/up")
    public CommonResult<D2dPickUpVO> doorToDoorPickUp(@RequestBody ReserveRentReturnPickUpReq req) {
        D2dPickUpVO d2dPickUpVO = new D2dPickUpVO();
        d2dPickUpVO.setSuccess(true);
        d2dPickUpVO.setDateDesc("今天");
        d2dPickUpVO.setStartTime(LocalTime.now().minusHours(2));
        d2dPickUpVO.setEndTime(LocalTime.now());
        d2dPickUpVO.setDeliveryName("顺丰快递");
        d2dPickUpVO.setPickUpCode("2830");
        d2dPickUpVO.setSenderName("张三");
        d2dPickUpVO.setSenderPhone("12353453232");
        d2dPickUpVO.setSenderAddress("上海市**区");
        return CommonResult.success(d2dPickUpVO);
    }

    @ApiOperation(value = "预约到店", tags = "承享/买入订单")
    @PostMapping("/return/appointment/shop")
    public CommonResult<AppointmentShopVo> appointmentShop(@RequestBody ReserveRentReturnPickUpReq req) {
        AppointmentShopVo appointmentShopVo = new AppointmentShopVo();
        appointmentShopVo.setSuccess(true);
        appointmentShopVo.setDateDesc("今天");
        appointmentShopVo.setStartTime(LocalTime.now().minusHours(2));
        appointmentShopVo.setEndTime(LocalTime.now());
        appointmentShopVo.setShopName("贝贝奢护管家");
        appointmentShopVo.setPhone("183082329023");
        appointmentShopVo.setShopAddress("上海市普陀区祁山路111弄7号");
        return CommonResult.success(appointmentShopVo);
    }

    @ApiOperation(value = "取消上门取件/预约到店", tags = "承享/买入订单")
    @PostMapping("/return/cancel/")
    public CommonResult<Void> cancelReturn(@RequestParam("orderNo") String orderNo) {
        return CommonResult.success();
    }

    @ApiOperation(value = "修改上门取件信息", tags = "承享/买入订单")
    @PostMapping("/return/door-to-door/pick/up/update")
    public CommonResult<Void> doorToDoorPickUpUpdate(@RequestBody ReserveRentReturnPickUpReq req) {
        return CommonResult.success();
    }

}
